package com.study.mybatis.type.handler.controller;

import com.study.mybatis.type.handler.entity.User;
import com.study.mybatis.type.handler.entity.UserExample;
import com.study.mybatis.type.handler.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : wilbur.yuan
 * @date : 2019-02-18
 */
@Slf4j
@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @PostMapping
    public Object add(@RequestBody User user) {

        log.info(user.toString());

        userMapper.insert(user);

        UserExample userExample = new UserExample();

        return userMapper.selectByExampleWithBLOBs(userExample);

    }

}
